package service

import (
	"context"
	"go.opentelemetry.io/otel"
	"go.opentelemetry.io/otel/trace"

	v1 "app_server/api/helloworld/v1"
	"app_server/internal/biz"
)

// GreeterService is a greeter service.
type GreeterService struct {
	v1.UnimplementedGreeterServer

	uc *biz.GreeterUsecase
}

// NewGreeterService new a greeter service.
func NewGreeterService(uc *biz.GreeterUsecase) *GreeterService {
	return &GreeterService{uc: uc}
}

func (s *GreeterService) HandleAmounts(ctx context.Context, req *v1.HandleAmountsRequest) (*v1.Empty, error) {
	ctx, span := otel.Tracer("Service").Start(ctx, "HandleAmountsService", trace.WithSpanKind(trace.SpanKindProducer))
	defer span.End()

	return s.uc.HandleAmounts(ctx, req)
}
